﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VicMessenger.DB;

namespace VicMessenger.DAL
{
    class CampaignDAL
    {
        public static List<proc_Campaign_SelectResult> GetCampaign(int? prmCampaignID, int? prmCategoryID)
        {
            try
            {
                using (CampaignDataContext db = new CampaignDataContext())
                {
                    return db.proc_Campaign_Select(prmCampaignID, prmCategoryID).ToList();
                }
            }
            catch (Exception)
            {
                return null;
            }
        }

        public static int? InsertUpdateCampaign(proc_Campaign_SelectResult prmCampaign)
        {
            try
            {
                int? retID = 0;
                using (CampaignDataContext db = new CampaignDataContext())
                {
                    db.proc_Campaign_InsertUpdate(prmCampaign.CampaignID,
                                                  prmCampaign.CampaignName,
                                                  prmCampaign.Description,
                                                  prmCampaign.CategoryID,
                                                  prmCampaign.LastRun,
                                                  ref retID);
                                                  



                    return retID;
                }
            }
            catch (Exception)
            {
                return 0;
            }
        }

        public static int DeleteCampaign(int prmCampaignID)
        {
            try
            {
                using (CampaignDataContext db = new CampaignDataContext())
                {
                    return db.proc_Campaign_Delete(prmCampaignID);
                }
            }
            catch (Exception)
            {
                return 0;
            }
        }
    
    }
}
